<?php
/**
	* Super Class
	*
	* @package Package Name
	* @subpackage Subpackage
	* @category Category
	* @author YinChuan  [hot530@126.com]
	* @link http://www.530Net.com
*/
class MY_Controller extends Controller {
	protected $data_config;
	function __construct()
	{
		parent::Controller();
		// <config>
		$this->data_config['base_url']		= $this->config->item('base_url');
		$this->data_config['base_img'] 		= $this->config->item('base_img');
		$this->data_config['base_img1'] 	= $this->config->item('base_img1');
		$this->data_config['base_header'] 	= $this->config->item('base_header');
		$this->data_config['base_view'] 	= $this->config->item('base_view');
		$this->data_config['site_name'] 	= $this->config->item('site_name');
		$this->data_config['site_keywords'] = $this->config->item('site_keywords');
		$this->data_config['site_desc'] 	= $this->config->item('site_desc');
		$this->data_config['site_tongji'] 		= $this->config->item('site_tongji');
		$this->data_config['k']='';
		// </config>
	}


	// ------------------------------------------------------------------------
	/**
		* 邮件发送
	*/
	private function mailsys($smtpemailto,$mailsubject,$mailbody,$accNum)
	{
		$this->load->model('smtp_model');
		// mailconfig
		$smtpserverport =	25;//SMTP服务器端口
		if($accNum==1){
			$smtpserver = 		$this->config->item('mail_Ser');//SMTP服务器
			$smtpusermail = 	$this->config->item('mail_SMTP');//SMTP服务器的用户邮箱
			$smtpuser = 		$this->config->item('mail_user');//SMTP服务器的用户帐号
			$smtppass = 		$this->config->item('mail_pwd');//SMTP服务器的用户密码
		}else{
			$smtpserver = 		$this->config->item('mail_Ser2');//SMTP服务器
			$smtpusermail = 	$this->config->item('mail_SMTP2');//SMTP服务器的用户邮箱
			$smtpuser = 		$this->config->item('mail_user2');//SMTP服务器的用户帐号
			$smtppass = 		$this->config->item('mail_pwd2');//SMTP服务器的用户密码
		}
		$mailtype = 		"HTML";//邮件格式（HTML/TXT）,TXT为文本邮件		
		// end mailconfig
		$this->smtp_model->smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
		$this->smtp_model->debug = FALSE;//是否显示发送的调试信息
		return $this->smtp_model->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);		
	}
	
	
	// 发送邮件 - 商家注册
	protected function tomail($uname,$activeurl,$tomail,$accNum=1)
	{
		$this->load->helper('mailbody');// 获得邮件的内容
		$uname = iconv("UTF-8","gb2312",$uname);
		$html = mailbody_reg($uname,$activeurl);
		$mailsubject=iconv("UTF-8","gb2312","家具369注册激活"); 
		$smtpemailto = 		"$reg_name";//发送给谁
		$this->mailsys($tomail,$mailsubject,$html,$accNum);		
	}


	// ------------------------------------------------------------------------
	/**
		* 个人发布家具，发送邮件
	*/
	protected function mail_user($onecontact,$proname,$prourl,$onepwd,$tomail='263708155@qq.com')
	{
		$this->load->helper('mailbody');
		$con =<<<DDD
		您好：$onecontact <br />
		您在家具369发布的信息：$proname <br />
		您的信息地址是：<a href="$prourl " target="_blank">$prourl</a><br />
		信息管理密码为：$onepwd<br />
		通过此密码，您可以对该信息进行 <br />
		1 修改；<br />
		2 下架（用户无法在网站查询到您的信息）；<br />
		3 更新操作（每天只能更新一次，更新后信息将显示在最前面）。<br />
		
DDD;

		$con=iconv("UTF-8","gb2312",$con);
		$html = mailbody_info2($con);
		$mailsubject=iconv("UTF-8","gb2312",$proname);
		$this->mailsys($tomail,$mailsubject,$html,2);// 1 这个帐户，腾讯邮箱收不到
	
	}
	






}//end class



